package com.yyq.common;

import com.sun.xml.internal.bind.v2.TODO;

import java.time.DateTimeException;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.temporal.TemporalAccessor;

/**
 * @author yyq
 * @create 2021-08-03 20:47
 */
public class YYQ_formatter {
    public static void main(String[] args) {
        //  实例化 格式化
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd-hh:mm-ss");
        String format = dateTimeFormatter.format(LocalDateTime.now());
        System.out.println(format);
        // 解析
        TemporalAccessor parse = dateTimeFormatter.parse("2021-08-03-08:50-34");
        System.out.println(parse);
        //dateTimeFormatter.parse()

    }
}
